<?php if (!defined('THINK_PATH')) exit();?><!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <style type="text/css">
            *{ padding: 0; margin: 0;font-size:16px; font-family: "微软雅黑"} 
            div{ padding: 3px 20px;} 
            body{ background: #fff; color: #333;}
            h2{font-size:36px}
            div.result{border:1px solid #d4d4d4; background:#FFC;color:#393939; padding:8px 10px;float:auto; width:97%;margin:2px}
            a{text-decoration:none; color:gray;}
            a:hover{color:#F60;}
            .divtext{width: 100%;height: 330px}
            div.page{border:1px solid #d4d4d4; background:#333;color:white; padding:5px 15px;float:auto; width:450px;margin:2px;text-align:right}
        </style>
    <script type="text/javascript" src="__PUBLIC__/js/htmlformat.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/js_beautify.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery.js"></script>
    <script type="text/javascript">
        function getHtml() {
            var tablename = $('#tablename').val();
          
            $.getJSON('__URL__/gethtml/tbname/' + tablename, function(res) {
                if (!res.status){
                    alert(res.info);
                }else{
                    $('#content').text(res.data);
                }
            });
        }
    </script>
</head>
<body>
    <script type="text/javascript">
        function do_js_beautify() {
            document.getElementById('beautify').disabled = true;
            js_source = document.getElementById('content').value.replace(/^\s+/, '');
            tabsize1 = document.getElementById('tabsize').value;
            tabchar = ' ';
            if (tabsize1 == 1) {
                tabchar = '\t';
            }
            if (js_source && js_source.charAt(0) === '<') {
                document.getElementById('content').value = style_html(js_source, tabsize1, tabchar, 80);
            } else {
                document.getElementById('content').value = js_beautify(js_source, tabsize1, tabchar);
            }
            document.getElementById('beautify').disabled = false;
            return false;
        }
        function Empty() {
            document.getElementById('content').value = '';
            document.getElementById('content').select();
        }
        function GetFocus() {
            document.getElementById('content').focus();
        }
        //复制按扭
        function copyHtml() {
            var obj = document.getElementById("content");
            obj.select();
            //js=obj.createTextRange();
            var js = obj.innerHTML;
            window.clipboardData.setData("Text", js);
            alert("已复制好，可贴粘。");

        }

    </script>
    <h2>表格HTML生成器</h2>
    <div class="result">
        <textarea class='divtext' id='content'><?php echo ($html); ?></textarea>
    </div>
    <div class="result">
        选择表名：<select name="tablename" id="tablename">
            <?php if(is_array($tablenames)): $i = 0; $__LIST__ = $tablenames;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["tablename"]); ?>"><?php echo ($vo["tablename"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
        </select>
        <input class="but2" type="button" value="生成" onclick="getHtml();" />
        <select name="tabsize" id="tabsize">
            <option value="1">
                制表符缩进
            </option>
            <option value="2" selected="selected">
                2个空格缩进
            </option>
            <option value="4">
                4个空格缩进
            </option>
            <option value="8">
                8个空格缩进
            </option>
        </select>

        <input class="but2" type="button" value="格式化" onclick="return do_js_beautify()" id="beautify" />
        <input class="but2" type="button" value="清空结果" onclick="Empty();" />
    </div>
</body>
</html>